home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / cacheviewer-0.4.7.1-fx.xpi / chrome / cacheviewer.jar / content / cacheviewer / overlay.js < prev    next >
Text File  |  2006-05-24  |  1KB  |  44 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents (ry
  5.  *
  6.  * ***** END LICENSE BLOCK *****
  7.  */
  8.  
  9. function showCacheViewer() {
  10.     var sepwin = gPrefService.getBoolPref("extensions.cacheviewer.open_in_separate_window");
  11.     var needToOpen = true;
  12.     var windowType = "CacheViewer";
  13.     if (sepwin) {
  14.         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  15.                     .getService(Components.interfaces.nsIWindowMediator);
  16.         var windows = wm.getEnumerator(windowType);
  17.         while (windows.hasMoreElements()) {
  18.             var theEM = windows.getNext().QueryInterface(Components.interfaces.nsIDOMWindowInternal);
  19.             if (theEM.document.documentElement.getAttribute("windowtype") == windowType) {
  20.                 theEM.focus();
  21.                 needToOpen = false;
  22.                  break;
  23.             }
  24.         }
  25.         if (needToOpen) {
  26.             const EMURL = "chrome://cacheviewer/content/cacheviewer.xul";
  27.             const EMFEATURES = "chrome, all, dialog=no, centerscreen";
  28.             window.openDialog(EMURL, "", EMFEATURES);
  29.         }
  30.     } else {
  31.         var tab = getBrowser().mTabContainer.firstChild;
  32.         while (tab) {
  33.             if (getBrowser().getBrowserForTab(tab).contentDocument.documentElement.getAttribute("windowtype") == windowType) {
  34.                 getBrowser().selectedTab = tab;
  35.                 needToOpen = false;
  36.                 break;
  37.             }
  38.             tab = tab.nextSibling;
  39.         }
  40.         if (needToOpen) {
  41.             getBrowser().selectedTab = getBrowser().addTab("chrome://cacheviewer/content/cacheviewer.xul");
  42.         }
  43.     }
  44. }